﻿package src {
	
	import flash.display.Sprite;
	
	/**
	 * An object to represent one track file
	 * @author Indrek Tamming
	 */
	public class ConservationData extends Sprite {
		
		/**
		 * The rows of the track file as strings
		 */
		private var conservationRows:Array;
		
		/**
		 * Init the object by adding the whole track file as parameter
		 * @param	tabFile	-	the track file as String
		 */
		public function ConservationData(tabFile:String):void {		// TODO: add name? et saaks panna mitu erinevat konserveeruvust
			this.conservationRows = tabFile.split("\n");
		}
		
		/**
		 * Get one row tab-split
		 * @param	rowNumber -	the number of row to get
		 * @return			-	the Array of split String
		 */
		public function getRow(rowNumber:int):Array {
			return String(conservationRows[rowNumber]).split("\t");
		}
		
		/**
		 * Calculate track maximum
		 * @return	-	 the maximum
		 */
		public function calculateMaximum():Number {
			var returner:Number = 0;
			for (var i:int = 0; i < conservationRows.length; i++) {
				var row:Array = String(conservationRows[i]).split("\t");
				for (var j:int = 0; j < row.length; j++) {
					var value:Number = row[j];
					if (value > returner) returner = value;
				}
			}
			return returner;
		}
		
	}
	
}